package cn.dnui_yxk801.dnuifood_16110100801.controller;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.List;

import cn.dnui_yxk801.dnuifood_16110100801.Adapter.MyCommentsAdapter;
import cn.dnui_yxk801.dnuifood_16110100801.R;
import cn.dnui_yxk801.dnuifood_16110100801.listener.OnRetrofitListener;
import cn.dnui_yxk801.dnuifood_16110100801.model.UserModel;

import static cn.dnui_yxk801.dnuifood_16110100801.MainActivity.userid;

public class MyCommentsActivity extends BaseActivity implements OnRetrofitListener{
    private RecyclerView rv_comments;
    @Override
    void initViews() {
        layout_file=R.layout.activity_my_comments;
        setLayout(layout_file);
        rv_comments=findViewById(R.id.rv_mycomments);
        rv_comments.setLayoutManager(new LinearLayoutManager(this));
        rv_comments.setHasFixedSize(true);
    }

    @Override
    void initEvents() {

    }

    @Override
    void initDatas() {
        UserModel userModel=new UserModel();
        userModel.getAllCommentsByUser(userid,this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public void onSuccess(Object object, int flag) {
        if (flag==5){
            List list=(List)object;
            MyCommentsAdapter myCommentsAdapter=new MyCommentsAdapter(this,list);
            rv_comments.setAdapter(myCommentsAdapter);
        }
    }

    @Override
    public void onFalure(String msg) {

    }
}
